<template>
  <div class="gold-shop-wrap">
    <van-nav-bar title="提现记录" left-arrow fixed @click-left="onClickLeft" />
    <div>
      <van-list
        v-model="loading"
        :finished="finished"
        finished-text="没有更多了"
        @load="onLoad"
      >
        <div class="team_list" v-for="(item, index) in fansList" :key="index">
          <div class="team_list_item">
            <img
              v-if="item.status == 120 || item.status == 110"
              src="../../../images/mine/icon_fail.png"
              alt=""
            />
            <img
              v-if="item.status == 10 || item.status == 20"
              src="../../../images/mine/icon_chuli.png"
              alt=""
            />
            <img
              v-if="item.status == 100"
              src="../../../images/mine/icon_success.png"
              alt=""
            />
            <div class="team_list_item_info">
              <div>{{ item.status==10?'处理中':item.status==20?'打款中':item.status==100?'打款成功':item.status==110?'已驳回'
              :item.status==120?'已失败':'-' }}</div>
              <div v-if="item.status==110">{{item.failure_reason}}</div>
              <div>
                {{ item.create_time }}
              </div>
            </div>
            <div class="record_money">
              <div>{{ item.amount }}</div>
              <div>{{ item.type_name }}</div>
            </div>
            <div class="close">
              <img :style="{opacity:item.status==110?1:0}" v-if="item.status==110" @click="handleClose(item.id)" src="../../../images/close-circle1.png" alt="">
              <img style="opacity: 0;" v-else src="../../../images/close-circle1.png" alt="">
            </div>
          </div>
        </div>
      </van-list>
    </div>
    <van-popup v-model="showEnd" :style="{ width: '80%' }" round>
            <div class="popup_title">
                <div class="msg-title">
                    <div
                        style="text-align: center;font-size: 0.28rem;font-weight: 500; margin-bottom: 0.2rem;color: #333;margin-top: -0.3rem;">
                        温馨提示</div>
                    <p> 删除记录后不可恢复，请确认是否删除？
                    </p>
                </div>
            </div>
            <div class="popup_btn_list">
                <van-button class="popup_btn" size="small" round @click="showEnd = false">取消</van-button>
                <van-button class="popup_btn" type="primary" size="small"
                    color="linear-gradient( 270deg, #1261E2 0%, #4A89EC 100%)" round
                    @click="orderSubmit">删除</van-button>
            </div>
        </van-popup>
  </div>
</template>
<script>
import { WITHDRAW_RECORD } from "@/api/mine";
export default {
  data() {
    return {
      finished: false,
      loading: false,
      page: 1,
      pageSize: 20,
      fansList: [],
      inviter_show: "",
      total_count: 0,
      showEnd:false,
      ids:''
    };
  },
  mounted() {
    window.scrollTo(0, 0)
  },
  methods: {
    onClickLeft() {
      this.$router.back();
    },
    onLoad() {
      let params = {};
      params["page_num"] = this.page;
      params["page_size"] = this.pageSize;
      // params['status'] = this.active;
      this.$http.get(WITHDRAW_RECORD, { params: params }).then((res) => {
        const { list } = res.data;
        this.total_count = res.data.pages.total_count;
        if (list && list.length) {
          this.page++;
          this.fansList = this.fansList.concat(list);

          // 加载状态结束
          this.loading = false;
          if (list.length < this.pageSize) {
            this.finished = true;
          }
        } else {
          this.finished = true;
        }
      });
    },
    handleClose(id){
      this.showEnd = true
      this.ids=id
    },
    orderSubmit(){
      this.$http.post('/withdraw/delete/'+this.ids).then(res=>{
        // if(res.code==200){
          this.$toast('删除成功')
          this.showEnd = false
          this.fansList = []
          this.page = 1
          this.onLoad()
          this.ids=''
        // }
      })
    },
  },
};
</script>
<style lang="scss" scoped>
.gold-shop-wrap {
  // min-height: 100vh;
  padding-top: 46px;
  // background: #F2F4F5;
  overflow: hidden;
  ::v-deep .van-nav-bar .van-icon {
    color: #333333;
  }

  ::v-deep .van-nav-bar__arrow {
    font-size: 20px;
  }
}

.team_list {
  width: 95%;
  margin: 0 auto;
  margin-top: 0.2rem;
  // border: 0.01rem solid #999;
  // border-radius: 0.16rem;
  background: #fff;

  .team_list_item {
    display: flex;
    justify-content: space-between;
    // padding: 0.24rem 0.32rem;
    border-bottom: 1px solid #e3e3e3;
    padding: 0.2rem 0.3rem;
    padding-right: 0;
    img {
      width: 0.45rem;
      height: 0.45rem;
      margin-top: 0.2rem;
      margin-right: 0.2rem;
    }

    .team_list_item_info {
      width: 50%;
      font-size: 0.28rem;
      line-height: 0.6rem;

      div:first-child {
        font-family: PingFangSC, PingFang SC;
        font-weight: 600;
        font-size: 0.28rem;
        color: #333333;
        line-height: 0.4rem;
        // text-align: left;
        font-style: normal;
      }
      div:nth-child(2){
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 0.24rem;
      }

      div:last-child {
        font-family: PingFangSC, PingFang SC;
        font-weight: 400;
        font-size: 0.24rem;
        color: #999999;
        // line-height: 17px;

        // text-align: center;
        font-style: normal;
      }
    }
    .close{
      width: .4rem;
      height: .4rem;
      img{
        width: 100%;
        height: 100%;
      }
    }
    .record_money {
      width: 37%;
      line-height: 0.6rem;
      font-size: 0.24rem;
      text-align: right;
      margin-right: .3rem;
      div:first-child {
        font-family: PingFangSC, PingFang SC;
        font-weight: 600;
        font-size: 0.32rem;
        color: #f32a23;
        line-height: 0.4rem;
        // text-align: center;
        font-style: normal;
      }

      div:last-child {
        font-family: PingFangSC, PingFang SC;
        font-weight: 400;
        font-size: .24rem;
        color: #666666;
        // line-height: 17px;
        // text-align: center;
        font-style: normal;
      }
    }
  }
}
.popup_title {
    text-align: center;
    font-family: PingFangSC, PingFang SC;
    font-weight: 400;
    font-size: 16px;
    color: #333333;
    line-height: 22px;
    font-style: normal;
    padding: 0.48rem 0;
}

.msg-title {
    padding: 0 .32rem;
    padding-top: .3rem;
    p {
        font-family: PingFangSC, PingFang SC;
        font-weight: 400;
        font-size: .28rem;
        color: #666666;
        line-height: .4rem;
        // text-indent: .4rem;
        text-align: center;
        font-style: normal;
    }
}

.popup_btn_list {
    width: 90%;
    margin: 0 auto;
    padding-bottom: .4rem;
    display: flex;
    justify-content: space-between;

    .popup_btn {
        width: 45%;
        height: .8rem;
        font-size: .32rem;
    }

}
</style>
